package com.example.service.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

public class DemoService extends Service {

    /**
     * 其他组件和service绑定通信
     *
     * @param intent
     * @return
     */
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.i("DemoService", "onBind");
        return null;
    }

    /**
     * service第一次创建会回调该方法
     */
    @Override
    public void onCreate() {
        Log.i("DemoService", "onCreate");
        super.onCreate();
    }

    /**
     * 每次调用startService(Intent)启动service时都会回调该方法
     *
     * @param intent
     * @param flags
     * @param startId
     * @return
     */
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i("DemoService", "onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    /**
     * 销毁service时执行的方法
     */
    @Override
    public void onDestroy() {
        Log.i("DemoService", "onDestroy");
        super.onDestroy();
    }

    /**
     * 组件解绑service时候执行的方法
     *
     * @param intent
     * @return
     */
    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("DemoService", "onUnbind");
        return super.onUnbind(intent);
    }


}
